package com.zz.hhbl.model

import com.zz.framework.core.http.BaseRepository
import com.zz.hhbl.api.ServiceFactory
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import okhttp3.MultipartBody
import okhttp3.RequestBody
import retrofit2.http.Body
import retrofit2.http.Part
import retrofit2.http.Query
import retrofit2.http.QueryMap
import java.net.HttpURLConnection
import java.net.URL

/**
 * Copyright © 2024 zhun All rights reserved.
 * Created by Zha0Zhun on 2024/6/11 10:19.
 * @author: Zha0Zhun 1820022519@qq.com
 * @version: V1.0
 */
class CommonHttpRepository : BaseRepository() {
    suspend fun login(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.loginDevice(params) }
    suspend fun getVersion(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.getVersion(params) }
    suspend fun getSpotInfo(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.getSpotInfo(params) }
    suspend fun getTourGuideCommentary(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.getTourGuideCommentary(params) }
    suspend fun fence(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.fence(params) }
    suspend fun digitalHuman(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.digitalHuman(params) }
    suspend fun syncDeviceStatus(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.syncDeviceStatus(params) }
    suspend fun fenceWarning(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.fenceWarning(params) }
    suspend fun getAllData(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.getAllData(params) }
    suspend fun getChatTokenConfig( deviceNumber: String?) = makeApiCall { ServiceFactory.apiService.getChatTokenConfig(deviceNumber) }
    suspend fun startVoiceChat(@QueryMap params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.startVoiceChat(params) }
    suspend fun stopVoiceChat( deviceNumber: String?) = makeApiCall { ServiceFactory.apiService.stopVoiceChat(deviceNumber) }
    suspend fun updateVoiceChat(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.updateVoiceChat(params) }
    suspend fun recordSosInfo(params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.recordSosInfo(params) }
    suspend fun getMapSpotPointMarks() = makeApiCall { ServiceFactory.apiService.getMapSpotPointMarks() }
    suspend fun audioCreate(sourceLanguage: RequestBody,
                            targetLanguage: RequestBody,
                            file: MultipartBody.Part,
    ) = callApi { ServiceFactory.apiService.audioCreate(sourceLanguage, targetLanguage, file) }
    suspend fun audioGetStatus(@Body params: HashMap<String, Any?>) = callApi { ServiceFactory.apiService.audioGetStatus(params) }
    suspend fun audioGetResult(@Body params: HashMap<String, Any?>) = makeApiCall { ServiceFactory.apiService.audioGetResult(params) }
}
